<template>
  <view class="container">
    <view class="records">
      <view class="records-item">
        <view class="time">日期</view>
        <view class="time">类型</view>
        <view class="score">积分</view>
        <view class="score t-right">变动后</view>
      </view>
      <view v-for="(item, i) in records" :key="i" class="records-item">
        <view class="time">{{ item.createTime }}</view>
        <view class="score">{{ item.statusStr }}</view>
        <view class="score">{{ item.integral }}</view>
        <view class="score">{{ item.afterIntegral }}</view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        records: [],
        isEnd: false,
      }
    },
    onLoad() {
      this.getRecord()
    },
    onReachBottom() {
      this.onNextPage()
    },
    methods: {
      initRecord() {
        this.page = 1
        this.records = []
        this.getRecord()
      },
      onNextPage() {
        if (this.isEnd != 1) {
          this.page ++
          this.getRecord()
        }
      },
      getRecord() {
        this.$http({
          url: '/member/getMyIntegralLogList',
          data: {
            page: this.page,
          }
        }).then(res => {
          this.records = this.records.concat(res.data.integralLogList)
          this.isEnd = res.data.isEnd
        })
      },
      
      onViewShop(item) {
        uni.navigateTo({
          url: `../goods/detail?id=${item.goodsId}`
        })
      },
     
      onToTabbar2() {
        wx.switchTab({
          url: '../goods/index'
        })
      },
    },
  }
</script>

<style lang="less">
  .container {
    padding: 20rpx;
    background-color: #fafafa;
    min-height: 100vh;
    
    .records{
      padding: 20rpx 0;
    }
    .records-item{
      margin-bottom: 20rpx;
      background: #fff;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 30rpx;
      line-height: 1;
      text-align: center;
    }
    .time{
      font-size: 28rpx;
      color: #666;
      flex: 1 0;
    }
    .score{
      font-size: 30rpx;
      color: #111;
      flex: 1 0;
    }
  }
</style>
